package xyz.xtgl.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;

import java.net.URI;

/**
 * 全局异常捕获处理
 * @author liubo
 * @created 2019-12-26 11:17
 */
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {


    @ExceptionHandler  //处理其他异常
    public void exception(Exception e, ServerRequest serverRequest,ServerResponse response){
        log.error("全局异常捕获",e);
        String TargetUrl = "https://www.xttblog.com";
        ServerResponse.temporaryRedirect(URI.create(TargetUrl)).build();
    }

}